package com.ctg.payroll2.action.common;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.ctg.payroll2.bean.filter.social.PbEmployeeFilter;
import com.ctg.payroll2.bean.po.SysUser;
import com.ctg.payroll2.service.common.EmployeeService;
import com.ctg.payroll2.util.Constants;
import com.ctg.platform.util.Page;
import com.ctg.platform.util.Parse;
import com.opensymphony.xwork2.ActionSupport;

public class EmployeeAction extends ActionSupport {
	private static final long serialVersionUID = -1920796839893006427L;
	private EmployeeService employeeService;
	private Page pbEmployeeResult;
	/**
	 * 员工查询的查询条件过滤器
	 */
	private PbEmployeeFilter pbEmployeeFilter;
	private SysUser getCurrentUser(){
		return (SysUser)ServletActionContext.getRequest().getSession().getAttribute(Constants.CURRENT_USER);
	}
	public String queryCsEmployeeResult(){
		SysUser u =  getCurrentUser();
		HttpServletRequest request = ServletActionContext.getRequest();
		if (pbEmployeeFilter==null) {
			pbEmployeeFilter = new PbEmployeeFilter();
		}
		pbEmployeeFilter.setStartIndex(Parse.toInteger(request.getParameter("start") , 0));
		pbEmployeeFilter.setEndIndex(Parse.toInteger(request.getParameter("limit"), Constants.DEFAULT_PAGE_SIZE));
		pbEmployeeFilter.setCompanyCode(u.getCompanyCode());
		pbEmployeeResult = employeeService.queryCsEmployee(pbEmployeeFilter);
		return SUCCESS;
	}

	/**
	 * @return 返回pbEmployeeFilter
	 */
	public PbEmployeeFilter getPbEmployeeFilter() {
		return pbEmployeeFilter;
	}
	/**
	 * @param pbEmployeeFilter 设置pbEmployeeFilter
	 */
	public void setPbEmployeeFilter(PbEmployeeFilter pbEmployeeFilter) {
		this.pbEmployeeFilter = pbEmployeeFilter;
	}
	/**
	 * @return 返回pbEmployeeResult
	 */
	public Page getPbEmployeeResult() {
		return pbEmployeeResult;
	}
	/**
	 * @param pbEmployeeResult 设置pbEmployeeResult
	 */
	public void setPbEmployeeResult(Page pbEmployeeResult) {
		this.pbEmployeeResult = pbEmployeeResult;
	}
	/**
	 * @param employeeService 设置employeeService
	 */
	public void setEmployeeService(EmployeeService employeeService) {
		this.employeeService = employeeService;
	}
	
}
